﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class ViewComments : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if(e.CommandName.Equals("flagComment")){

        DVDTableAdapters.FlaggedCommentTableAdapter ta = new DVDTableAdapters.FlaggedCommentTableAdapter();
        TableCell CommentID = GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0];
        ta.Insert(Convert.ToInt32(CommentID.Text));

        }
        else if(e.CommandName.Equals("deleteComment"))
        {
            MembershipUser user = Membership.GetUser();
            if(user.ProviderName.Equals("admin"))
            {
                TableCell CommentID = GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0];
                try
                {
                    DVDTableAdapters.FlaggedCommentTableAdapter ta = new DVDTableAdapters.FlaggedCommentTableAdapter();
                    ta.DeleteQuery(Convert.ToInt32(CommentID.Text));
                }
                catch { }
                DVDTableAdapters.CommentTableAdapter ta1 = new DVDTableAdapters.CommentTableAdapter();
                ta1.DeleteQuery(Convert.ToInt32(CommentID.Text));
            }

        }
    }
}